import time
import datetime

print(time.time())       # 1549248344.7600589
print(time.localtime())  # time.struct_time(tm_year=2019, tm_mon=2, tm_mday=4, tm_hour=10, tm_min=45, tm_sec=44, tm_wday=0, tm_yday=35, tm_isdst=0)
print(time.strftime('%Y-%m-%d %H:%M:%S'))   # 2019-02-04 10:45:12
print(time.strftime('%Y%m%d %H-%M-%S'))     # 20190204 10-45-44


print(datetime.datetime.now())              # 2019-02-04 10:49:02.243483
new_time = datetime.timedelta(minutes=10)
# 10分钟后的时间
print(datetime.datetime.now() + new_time)   # 2019-02-04 10:59:02.243524

# 定义某一天的日期，时间
one_day = datetime.datetime(2020, 5, 20, 10, 20, 30)
print(one_day)                              # 2020-05-20 10:20:30
new_day = datetime.timedelta(days=10, hours=20, minutes=30, seconds=40)
print(one_day + new_day)                    # 2020-05-31 06:51:10
